package com.powernode.spring6.bean3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Product {

    /*@Value("张三")
    private String name;

    @Value("30")
    private int age;*/
    private String name;
    private int age;

    public Product(@Value("李四") String name, @Value("234") int age) {
        this.name = name;
        this.age = age;
    }


    // 注意：@Value注解也可以用在方法上
    /*@Value("张三sada")
    public void setName(String name) {
        this.name = name;
    }

    @Value("3000")
    public void setAge(int age) {
        this.age = age;
    }*/



    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
